Skip to content

Add Connect API contract test harness (connect-api-contracts)#3644

Closed
zackverham wants to merge 3 commits intomainfrom
zverham/connect-api-contract-tests
Closed

Add Connect API contract test harness (connect-api-contracts)#3644
zackverham wants to merge 3 commits intomainfrom
zverham/connect-api-contract-tests

Conversation

@zackverham
Copy link
Collaborator

Summary

  • Introduces test/connect-api-contracts/ — a contract test suite that validates how Publisher communicates with Posit Connect's API
  • Covers all 15 APIClient methods: authentication, content CRUD, bundles, tasks, settings, integrations, and deployment validation
  • Uses a mock Connect server with a response override mechanism for per-test error scenario configuration
  • Includes error response coverage: 401 auth failures, locked/unconfirmed/viewer users, task failures, validation errors, and generic HTTP errors
  • Adds just test-connect-contracts recipe

Context

Split from #3640 into three focused PRs:

  • test/api-contracts/ — Publisher API contract tests (separate PR)
  • This PR: test/connect-api-contracts/ — Connect API contract tests
  • test/extension-api-contracts/ — Extension API contract tests (separate PR)

Test plan

  • just build && just test-connect-contracts passes (12 active tests, rest skipped)
  • Mock override mechanism resets between tests (no bleed-over)
  • Error fixture files parse as valid JSON

🤖 Generated with Claude Code

…ehavior

Introduces a contract test suite in test/connect-api-contracts/ that validates
how the Publisher communicates with Posit Connect's API. Tests cover all 15
APIClient methods (authentication, content CRUD, bundles, tasks, settings,
integrations, deployment validation) using a mock Connect server.

Includes error response coverage for authentication (401, locked user,
unconfirmed user, viewer role), task failures, validation errors, and
generic HTTP errors. A response override mechanism enables per-test
mock configuration for error scenarios.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zackverham zackverham requested a review from a team as a code owner March 3, 2026 21:45
zackverham and others added 2 commits March 3, 2026 17:45
Replace the previous approach (routing through Publisher's HTTP API) with a
thin Go harness that wraps each APIClient method as its own endpoint. This
lets every method be tested independently without needing a standalone
Publisher API trigger.

- Create harness/main.go with 15 POST endpoints (one per APIClient method)
- Rewrite setup.ts to build and spawn the harness instead of the publisher binary
- Rewrite go-publisher-client.ts to call harness endpoints
- Un-skip all 14 previously skipped test suites (81 tests now pass)
- Update authentication tests to match harness response shape
- Add clearMockOverrides to all beforeEach hooks to prevent cross-file contamination
- Disable vitest file parallelism (shared mock server)
- Add build-connect-harness recipe to justfile

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…agement

Replace 15 separate handler functions with a single POST /call endpoint
that dispatches via a switch on the method name. Move mock request
clear/fetch into the harness so the TS client no longer manages mock
state directly.

- main.go: 468 → 262 lines (single handleCall + dispatch function)
- go-publisher-client.ts: 280 → 106 lines (one-liner methods via generic call helper)
- get-settings.test.ts: uses capturedRequests from harness response instead of getMockRequests()
- client.ts: add optional capturedRequests array to ConnectContractResult

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zackverham zackverham marked this pull request as draft March 4, 2026 15:51
@zackverham zackverham closed this Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant